package com.zzz.controller;

import com.zzz.bean.User;
import com.zzz.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author aXuan-zmx
 * @project com.zzz
 * @create 2021-04-29 21:05
 * @description 功能描述
 */
@Controller
public class UserController {
    @Autowired
    private UserService service;

    @RequestMapping("/findAll")
    public String findAll(Model model){
        System.out.println("success");
        List<User> all = service.findAll();
        model.addAttribute("user",all);
        return "list";
    }

    @RequestMapping("/save")
    public String save(){
        User user=new User();
        user.setName("张洁雨");
        user.setGender("女");
        user.setEmail("2895855830@qq.com");
        boolean b = service.save(user);
        return "success";
    }
}
